import { math, Vec3 } from "cc";

export class MathUtil {


    static isHitRate(rate: number): boolean {
        return rate > Math.random();
    }

    static getDistance(p1: Vec3, p2: Vec3): number {
        return Math.sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
    }

    static getAngle(p1: Vec3, p2: Vec3): number {
        let angle = Math.atan2(p2.y - p1.y, p2.x - p1.x)
        return angle
    }
}